package org.example.pojo;

import lombok.Data;

/**
 * 封装返回结果实体封装
 */
@Data
public class Result {
    private Integer code;//状态码  1成功 0 失败
    private String msg;//提示信息  "secucess"
    private Object data;//数据

    public static Result success() {//成功情况 不返回数据
        Result result = new Result();
        result.code = 1;
        result.msg = "success";
        return result;
    }

    public static Result error(String msg) {//失败情况
        Result result = new Result();
        result.code = 0;
        result.msg = msg;
        return result;
    }

    public static Result success(Object object) {//成功情况 返回数据
        Result result = new Result();
        result.data = object;
        result.code = 1;
        result.msg = "success";
        return result;
    }
}
